#include "LinkStack.h"
#include <stdio.h>

#define true 1
#define false 0

int InitLStack(LStack *s)
{

    return InitDLlist(&s->stack);
}

void SPush(LStack *s, ElementType element)
{
    InsertTail(&s->stack, element);
}

ElementType *SPop(LStack *s)
{
    if (s->stack.len == 0)
    {
        printf("The stack is empty\n");
        return NULL;
    }
    s->TopElement = s->stack.tail->data;
    RemoveByIndex(&s->stack, s->stack.len - 1);
    return &s->TopElement;
}

struct Node *GetTop(LStack *s)
{

    return s->stack.tail;
}

int IsEmpty(LStack *s)
{
    if (s->stack.len == 0)
    {
        return true;
    }
    return false;
}

void StackTravel(LStack *s)
{
    Travel(&s->stack);
}

void FreeLStack(LStack *s)
{
    FreeDLlist(&s->stack);
}